import time

def getCharge(drinkNo, foodNo):
    drinkCharge = 0.0
    foodCharge = 0.0
    if drinkNo == 1:
        drinkCharge = 3.0
    elif drinkNo == 2:
        drinkCharge = 4.5
    elif drinkNo == 3:
        drinkCharge = 4.0
    if foodNo == 1:
        foodCharge = 1.0
    elif foodNo == 2:
        foodCharge = 2.5
    elif foodNo == 3:
        foodCharge = 2.0
    elif foodNo == 4:
        foodCharge = 1.5
    return drinkCharge + foodCharge


def orderMenu(DrinkMenu,FoodMenu,OrderList):
    print("\n---- 欢迎点餐 ----")
    print("我们提供的饮品：")
    for drink in DrinkMenu.keys():
        print(str(drink) + ": " + DrinkMenu[drink])
    drinkNo = int(input("请输入序号选择您需要的饮品(1~3)："))
    print(drinkNo)
    while drinkNo > 3:
        drinkNo = int(input("输入错误。请输入序号选择您需要的饮品(1~3)："))

    print("您选择了：" + DrinkMenu[drinkNo] + "\n")

    print("我们提供的食物：")
    for food in FoodMenu.keys():
        print(str(food) + ": " + FoodMenu[food])
    foodNo = int(input("请输入序号选择您需要的食物(1~4)："))
    while foodNo > 4:
        foodNo = int(input("输入错误。请输入序号选择您需要的食物(1~4)："))
    print("您选择了：" + FoodMenu[foodNo] + "\n")

    totalPrice = getCharge(drinkNo, foodNo)
    print("将马上为您奉上%s和%s，共消费%.2f元。" % (DrinkMenu[drinkNo], FoodMenu[foodNo], totalPrice))

    OrderDate = time.strftime('%Y-%m-%d', time.localtime(time.time()))
    OrderTime = time.strftime('%H:%M:%S', time.localtime(time.time()))
    OrderList.append([OrderDate, OrderTime, DrinkMenu[drinkNo], FoodMenu[foodNo], totalPrice])
    return OrderList

def printReport(OrderList):
    totalPrice = 0
    print("\n------------------------ 统计报表 ------------------------\n")
    print(" 点餐日期 \t点餐时间 \t饮料\t主食 \花费(元)")
    for order in OrderList:
        totalPrice += order[4]
        print(order[0] + "\t" + order[1] + "\t%s\t%s\t%.2f" % (order[2], order[3], order[4]))
    print("\n累计收入 %.2f 元。" % totalPrice)


def exportReport(OrderList):
    dataFile = open("AllReport.txt", "w")
    for order in OrderList:
        dataFile.write(order[0] + "," + order[1] + ",%s,%s,%.2f元\n" % (order[2], order[3], order[4]))
    dataFile.close()
    print("---- 成功导出报表。 ----")